<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
{template index/header}
    <div class="subnav">
        <a href="">首页</a> &gt; <a href="">客户管理</a> &gt; <a href="index.php?m=user&c=letter_add">站内信</a>
    </div>
    <div class="main-inner">
        <div class="x-body">
        	<form class="layui-form" action="index.php?m=user&c=letter" id="myform" method="post">
            <div class="tablefilter">
                <div class="tablebutton">
                    <a href="index.php?m=user&c=letter_add" class=""><i class="fa fa-plus"></i>发送站内信</a>
                    <a href="javascript:void(0);" onclick="choose_all();"><i class="fa fa-check"></i>全选</a>
                    <a href="javascript:void(0);" onclick="del();"><i class="fa fa-trash"></i>删除</a>
                </div>
                <em>状态</em>
                <div class="left margin-l10">
                    <select name="is_read" onchange="choose_read();">
                        <option value="0" selected="selected">全部</option>
                        <option value="1" {if $is_read=="1"} selected {/if}>已阅读</option>
                        <option value="2" {if $is_read=="2"} selected {/if}>未阅读</option>
                    </select>
                </div>
                <div class="tableFilterInput">
                    <em>收件人</em><input type="text" name="recipient" value="{$recipient}">
                </div>
                <div class="tableFilterInput">
                    <em>标题</em><input type="text" name="title" value="{$title}">
                </div>
                <div class="tableButton">
                    <input type="submit" name="search" class="layui-btn" value="查询">
                </div>
            </div>
			</form>
            <table class="layui-table">
                <thead>
                    <tr>
                        <th>选择</th>
                        <th>类型</th>
                        <th>收件人</th>
                        <th>标题</th>
                        <th>状态</th>
                        <th>添加时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody id="datalist">
                	{loop $data as $key=>$val}
                   <tr id="tr_$val['id']">
                        <td>
                            <input type="checkbox" name="ids[$key]" class="del" value="{$val['id']}" />
                        </td>
                        <td>{if $val['mail_type']=="1"}系统消息{/if}</td>
                        <td>{$val['recipient']}</td>
                        <td>{$val['title']}</td>
                        <td>{if $val['is_read']=="1"}已阅读{else}未阅读{/if}</td>
                        <td>{date('Y-m-d',$val['dateline'])}</td>
                        <td><a href="?m=user&c=letter_add&id={$val['id']}" style="color:#2a72c5;">查看</a></td>
                                            
                    </tr>
                    {/loop}      
                </tbody>
            </table>
            <div class="layui-clear">
                <div id="pages" class="layui-laypage">{$multi}</div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function choose_all(){
    		$(".del").each(function(n,j){
    			if(!$(this).is(":checked")){
    				$(this).prop("checked",true);	
    			}else{
    				$(this).removeAttr("checked",false);
    			}
    		})
        }
    	   
    	function del(){
    		var arr = [];
    		$(".del").each(function(n,j){
				if($(this).is(":checked")){
					arr.push($(this).val());
				}
			});
    		$.post('?m=user&c=letter&a=del',{
				'del_ids': arr
			},function (json){
				if(json.status=="1"){
					alert("删除成功！");
					location.href=location.href;
				}else{
					alert("失败");
				}
			},'json');	
        }

		function choose_read(){
			$("#myform").submit();
		}

        	
    </script>
    
    
    
{template index/footer}
